<?php

class userControl extends CI_Controller {

    function __construct() {
        parent::__construct();
        //cargamos el odelo para que todas las funciones las usen si es necesario
        $this->load->model('user');
    }

    public function subscribe() {
        if ($this->input->post()) {
            $id_user = $this->session->userdata["logged_in"]["id"];
            $id_activity = $this->input->post("id_activity");

            $this->load->model('user_activity');
            $data_UA = array("id_user" => $id_user, "id_activity" => $id_activity);
            $this->user_activity->add_UA($data_UA);

            $sess_array = array('type' => 'good', 'text' => 'Subscribe Succeed');
            $this->session->set_userdata('notification', $sess_array);
            redirect('/activity/show', 'refresh');
        }
    }
     public function unsubscribe() {
        if ($this->input->post()) {
            $id_user = $this->session->userdata["logged_in"]["id"];
            $id_activity = $this->input->post("id_activity");

            $this->load->model('user_activity');
           
            $this->user_activity->delete_UA($id_user,$id_activity);

            $sess_array = array('type' => 'good', 'text' => 'Unsubscribe Succeed');
            $this->session->set_userdata('notification', $sess_array);
            redirect('/activity/show', 'refresh');
        }
    }

}
?>
	
